<template>
  <div class="recommend">
    <div class="recomment-head">
      <h4>精品推荐</h4>
      <a href="javascript:;">
        >
      </a>
    </div>
    <div class="recommend-main">
      <div class="item"
        v-for="item in recommends"
        :key="item.id"
        @click="clickItem(item.id)"
        >
        <img v-lazy="item.pic" alt="">
        <h5>{{item.name}}</h5>
        <div class="action">
          <span class="price">
            {{ item.minPrice | currency }}
          </span>
          <van-icon
            @click.stop="clickAddCart(item)"
            size="20" color="#f66" class="iconfont" class-prefix="icon" name="wuuiconxiangjifangda"></van-icon>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { currency } from '@filters'
export default {
  props: {
    recommends: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickAddCart (item) {
      this.$emit('clickAddCart', item)
    },
    clickItem (id) {
      this.$emit('click', id)
    }
  },
  filters: {
    currency
  }
}
</script>

<style lang="scss" scoped>
.recommend{
  .recomment-head{
    line-height: 50px;
    display: flex;
    padding:0 10px;
    box-sizing: border-box;
    justify-content: space-between;
    background: #f1f1f1;
    h4{
      margin:0;
      font-size:18px;
      color:#333;
    }
    a{
      font-size:22px;
      color:#333;
    }
  }
  .recommend-main{
    display: flex;
    flex-wrap: wrap;
    .item{
      width:50%;
      box-sizing: border-box;
      padding:0 8px;
      h5{
        line-height: 30px;
        font-size:14px;
        color:#333;
      }
      .action{
        display: flex;
        justify-content: space-between;
        .price{
          font-size:18px;
          color:#f66;
        }


      }
      img{
        width:100%;
      }
    }
  }
}
</style>
